/*
 *  SableJBDD, a Java Binary Decision Diagram package.
 *  Copyright (C) 2003  Feng Qian
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
//$Id: UniqueObject.java,v 1.4 2004/03/08 04:28:31 fqian Exp $
package SableJBDD.bdd.internal;

/**
 * A unique object assigns a unique id to each instance of its subclasses.
 *
 * @author Feng Qian
 */
public class UniqueObject implements Unique {
  private static int total_objects = Integer.MIN_VALUE;
  private static Object lock = new Object();
  private final int id;
  public UniqueObject() {
    synchronized(lock) {
      this.id = total_objects ++;
    }
    // assert total_objects <= Long.MAX_VALUE;
  }
  public int getUniqueId() {return this.id;}

  public int hashCode() {
    return this.id;
  }

  public boolean equals(Object other) {
    return this == other;
  }
}
